package com.example.myProxy;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

@Configuration
@Import({MyRegister.MyMapperScanner.class})
public class MyRegister {

    public static class MyMapperScanner implements ImportBeanDefinitionRegistrar {

        @Override
        public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
            AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(MyInterface.class).getBeanDefinition();
            beanDefinition.setBeanClass(MyFactory.class);
            registry.registerBeanDefinition("com.example.myProxy.MyInterface",beanDefinition);
        }

    }
}
